home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / UDPCMD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-06  |  1.9 KB  |  106 lines

  1. /* UDP-related user commands
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include "global.h"
  5. #include "commands.h"
  6. #ifdef MSDOS
  7. #include "socket.h"
  8. #else
  9. #include "mbuf.h"
  10. #endif
  11. #include "netuser.h"
  12. #include "udp.h"
  13.  
  14. #if !defined(_lint)
  15. static char rcsid[] OPTIONAL = "$Id: udpcmd.c,v 1.16 1997/09/07 00:31:16 root Exp root $";
  16. #endif
  17.  
  18. #ifdef  UDPACCESS
  19. static int douaccess (int argc, char *argv[], void *p);
  20. extern int do_tcpudp_access (int argc, char *argv[], void *p);
  21.  
  22. struct rtaccess *UDPaccess = NULLACCESS;       /* access list */
  23. #endif
  24.  
  25. static int doudpstat (int argc,char *argv[],void *p);
  26.  
  27. static struct cmds Udpcmds[] = {
  28. #ifdef UDPACCESS
  29.     { "access",    douaccess,    0, 0,    NULLCHAR },
  30. #endif
  31.     { "status",    doudpstat,    0, 0,    NULLCHAR },
  32.     { NULLCHAR,    NULL,        0, 0,    NULLCHAR }
  33. };
  34.  
  35.  
  36. int
  37. doudp (argc, argv, p)
  38. int argc;
  39. char *argv[];
  40. void *p;
  41. {
  42.     return (subcmd (Udpcmds, argc, argv, p));
  43. }
  44.  
  45.  
  46. int
  47. st_udp (udp, n)
  48. struct udp_cb *udp;
  49. int n;
  50. {
  51.     if (n == 0)
  52.         tputs ("&UCB Rcv-Q  Local socket\n");
  53. #ifdef UNIX
  54.     return tprintf ("%8.8lx%6u  %s\n",
  55. #else
  56.     return tprintf ("%4.4x%6u  %s\n",
  57. #endif
  58.         (unsigned long) udp, udp->rcvcnt, pinet (&udp->socket));
  59. }
  60.  
  61.  
  62. /* Dump UDP statistics and control blocks */
  63. static int
  64. doudpstat (argc, argv, p)
  65. int argc OPTIONAL;
  66. char *argv[] OPTIONAL;
  67. void *p OPTIONAL;
  68. {
  69. register struct udp_cb *udp;
  70. register int i;
  71.  
  72.     for (i = 1; i <= NUMUDPMIB; i++)    {
  73.         tprintf ("(%2u)%-20s%10lu", i, Udp_mib[i].name, Udp_mib[i].value.integer);
  74.         if (i % 2)
  75.             tputs("     ");
  76.         else
  77.             tputc('\n');
  78.     }
  79.     if ((i % 2) == 0)
  80.         tputc('\n');
  81.  
  82.     tputs ("&UCB Rcv-Q  Local socket\n");
  83.     for (udp = Udps; udp != NULLUDP; udp = udp->next)    {
  84.         if (st_udp (udp, 1) == EOF)
  85.             return 0;
  86.     }
  87.     return 0;
  88. }
  89.  
  90.  
  91. #ifdef  UDPACCESS
  92.  
  93. static int
  94. douaccess (argc, argv, p)
  95. int argc;
  96. char *argv[];
  97. void *p OPTIONAL;
  98. {
  99.     return (do_tcpudp_access (argc, argv, &UDPaccess));
  100. }
  101.  
  102. #endif
  103.  
  104.  
  105.  
  106.